home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / musicali / 8to16.lha / 8_to_16 / Sources / PhxMacros.i < prev   
Text File  |  1992-09-02  |  8KB  |  380 lines

  1. *****************************************************************
  2. *                                                               *
  3. *       PhxMacro.i      PhxAss Macro Extension                  *
  4. *                                                               *
  5. *****************************************************************
  6. *
  7. *       $VER: PhxMacro 1.3 (14.10.96)
  8. *       (C) 1996 Richard Körber -- All rights reserved
  9. *
  10. *       Requires PhxAss V4.33 or higher!
  11. *
  12. * 1.3   21.10.96 (shred) renamed peek to top, took def2 from phx,
  13. *                      added args and unargs
  14. *
  15. * 1.2   14.10.96 (phx) removed IFCPU macro, fixed ODD macro,
  16. *                      fixed FLIP macro, fixed EXTBL macro,
  17. *                      added another (better) DEF macro, called DEF2.
  18. *
  19. *****************************************************************
  20.  
  21.         IFND    _PHXMACRO_I
  22. _PHXMACRO_I     SET     -1
  23.  
  24. align           MACRO                   ;align <val>
  25.         cnop    0,\1
  26.         ENDM
  27.  
  28. odd             MACRO                   ;opposite of 'even'
  29.         cnop    1,2
  30.         ENDM
  31.  
  32. inc             MACRO                   ;increment
  33.         addq.\0 #1,\1           ;  inc.(b|w|l) <ea>
  34.         ENDM
  35.  
  36. dec             MACRO                   ;decrement
  37.         subq.\0 #1,\1           ;  dec.(b|w|l) <ea>
  38.         ENDM
  39.  
  40. push            MACRO                   ;push to stack
  41.         move.\0 \1,-(sp)        ;  push.(w|l)  <ea>
  42.         ENDM
  43.  
  44. top             MACRO                   ;top stack
  45.         move.\0 (sp),\1         ;  top.(w|l)  <ea>
  46.         ENDM
  47.  
  48. pop             MACRO                   ;pop from stack
  49.         move.\0 (sp)+,\1        ;  pop.(w|l)   <ea>
  50.         ENDM
  51.  
  52. pushm           MACRO                   ;push register set to stack
  53.         movem.\0 \1,-(sp)       ;  pushm.(w|l) <set>
  54.         ENDM
  55.  
  56. pushem          MACRO                   ;DevPac compatibility
  57.         movem.\0 \1,-(sp)       ;  pushem.(w|l) <set>
  58.         ENDM
  59.  
  60. topm            MACRO                   ;top register SET
  61.         movem.\0 (sp),\1        ;  topm.(w|l) <set>
  62.         ENDM
  63.  
  64. popm            MACRO                   ;pop register set
  65.         movem.\0 (sp)+,\1       ;  popm.(w|l)   <set>
  66.         ENDM
  67.  
  68. popem           MACRO                   ;DevPac compatibility
  69.         movem.\0 (sp)+,\1       ;  popem.(w|l)   <set>
  70.         ENDM
  71.  
  72. store           MACRO                   ;Push all registers
  73.         movem.l d0-d7/a0-a6,-(sp)
  74.         ENDM
  75.  
  76. recall          MACRO                   ;Restore all registers
  77.         movem.l (sp)+,d0-d7/a0-a6
  78.         ENDM
  79.  
  80. rhi             MACRO                   ;Return when higher
  81.         bls.b   .jmp\@
  82.         rts
  83. .jmp\@
  84.         ENDM
  85.  
  86. rls             MACRO                   ;Return when lower/same
  87.         bhi.b   .jmp\@
  88.         rts
  89. .jmp\@
  90.         ENDM
  91.  
  92. rcc             MACRO                   ;Return when carry clear
  93.         bhi.b   .jmp\@
  94.         rts
  95. .jmp\@
  96.         ENDM
  97.  
  98. rhs             MACRO                   ;Return when higher/same
  99.         bcs.b   .jmp\@
  100.         rts
  101. .jmp\@
  102.         ENDM
  103.  
  104. rcs             MACRO                   ;Return when carry set
  105.         bcc.b   .jmp\@
  106.         rts
  107. .jmp\@
  108.         ENDM
  109.  
  110. rne             MACRO                   ;Return when not equal
  111.         beq.b   .jmp\@
  112.         rts
  113. .jmp\@
  114.         ENDM
  115.  
  116. req             MACRO                   ;Return when equal
  117.         bne.b   .jmp\@
  118.         rts
  119. .jmp\@
  120.         ENDM
  121.  
  122. rvc             MACRO                   ;Return when overflow clear
  123.         bvs.b   .jmp\@
  124.         rts
  125. .jmp\@
  126.         ENDM
  127.  
  128. rvs             MACRO                   ;Return when overflow set
  129.         bvc.b   .jmp\@
  130.         rts
  131. .jmp\@
  132.         ENDM
  133.  
  134. rpl             MACRO                   ;Return when plus
  135.         bmi.b   .jmp\@
  136.         rts
  137. .jmp\@
  138.         ENDM
  139.  
  140. rmi             MACRO                   ;Return when minus
  141.         bpl.b   .jmp\@
  142.         rts
  143. .jmp\@
  144.         ENDM
  145.  
  146. rge             MACRO                   ;Return when greater/equal
  147.         blt.b   .jmp\@
  148.         rts
  149. .jmp\@
  150.         ENDM
  151.  
  152. rlt             MACRO                   ;Return when less than
  153.         bge.b   .jmp\@
  154.         rts
  155. .jmp\@
  156.         ENDM
  157.  
  158. rgt             MACRO                   ;Return when greater than
  159.         ble.b   .jmp\@
  160.         rts
  161. .jmp\@
  162.         ENDM
  163.  
  164. rle             MACRO                   ;Return when less/equal
  165.         bgt.b   .jmp\@
  166.         rts
  167. .jmp\@
  168.         ENDM
  169.  
  170. bsrhi           MACRO                   ;Branch when higher
  171.         bls.b   .jmp\@
  172.         bsr.\0  \1
  173. .jmp\@
  174.         ENDM
  175.  
  176. bsrls           MACRO                   ;Branch when lower/same
  177.         bhi.b   .jmp\@
  178.         bsr.\0  \1
  179. .jmp\@
  180.         ENDM
  181.  
  182. bsrcc           MACRO                   ;Branch when carry clear
  183.         bhi.b   .jmp\@
  184.         bsr.\0  \1
  185. .jmp\@
  186.         ENDM
  187.  
  188. bsrhs           MACRO                   ;Branch when higher/same
  189.         bcs.b   .jmp\@
  190.         bsr.\0  \1
  191. .jmp\@
  192.         ENDM
  193.  
  194. bsrcs           MACRO                   ;Branch when carry set
  195.         bcc.b   .jmp\@
  196.         bsr.\0  \1
  197. .jmp\@
  198.         ENDM
  199.  
  200. bsrne           MACRO                   ;Branch when not equal
  201.         beq.b   .jmp\@
  202.         bsr.\0  \1
  203. .jmp\@
  204.         ENDM
  205.  
  206. bsreq           MACRO                   ;Branch when equal
  207.         bne.b   .jmp\@
  208.         bsr.\0  \1
  209. .jmp\@
  210.         ENDM
  211.  
  212. bsrvc           MACRO                   ;Branch when overflow clear
  213.         bvs.b   .jmp\@
  214.         bsr.\0  \1
  215. .jmp\@
  216.         ENDM
  217.  
  218. bsrvs           MACRO                   ;Branch when overflow set
  219.         bvc.b   .jmp\@
  220.         bsr.\0  \1
  221. .jmp\@
  222.         ENDM
  223.  
  224. bsrpl           MACRO                   ;Branch when plus
  225.         bmi.b   .jmp\@
  226.         bsr.\0  \1
  227. .jmp\@
  228.         ENDM
  229.  
  230. bsrmi           MACRO                   ;Branch when minus
  231.         bpl.b   .jmp\@
  232.         bsr.\0  \1
  233. .jmp\@
  234.         ENDM
  235.  
  236. bsrge           MACRO                   ;Branch when greater/equal
  237.         blt.b   .jmp\@
  238.         bsr.\0  \1
  239. .jmp\@
  240.         ENDM
  241.  
  242. bsrlt           MACRO                   ;Branch when less than
  243.         bge.b   .jmp\@
  244.         bsr.\0  \1
  245. .jmp\@
  246.         ENDM
  247.  
  248. bsrgt           MACRO                   ;Branch when greater than
  249.         ble.b   .jmp\@
  250.         bsr.\0  \1
  251. .jmp\@
  252.         ENDM
  253.  
  254. bsrle           MACRO                   ;Branch when less/equal
  255.         bgt.b   .jmp\@
  256.         bsr.\0  \1
  257. .jmp\@
  258.         ENDM
  259.  
  260. flip            MACRO                   ;flip big<->little endian
  261.         IFC     "\0","L"        ;  flip.(w|l)  <data register>
  262.          ror    #8,\1
  263.          swap   \1
  264.          ror    #8,\1
  265.         ELSE
  266.          IFC    "\0","W"
  267.           ror   #8,\1
  268.          ENDC
  269.         ENDC
  270.         ENDM
  271.  
  272. extbl           MACRO                   ;extb.l for 68000, auto optimizing
  273.         IFGE    __CPU-68020     ;  extbl  <data register>
  274.          extb.l \1
  275.         ELSE
  276.          ext.w  \1
  277.          ext.l  \1
  278.         ENDC
  279.         ENDM
  280.  
  281. proc            MACRO                   ;procedure header
  282. __REG\1         REG     \2              ;  proc  <name>,<registerset>
  283. \1              pushm.l __REG\1
  284.         ENDM
  285.  
  286. xproc           MACRO                   ;procedure header with reference
  287. __REG\1         REG     \2              ;  xproc  <name>,<registerset>
  288. \1              pushm.l __REG\1
  289.         XDEF    \1
  290.         ENDM
  291.  
  292. endp            MACRO                   ;procedure end
  293.         popm.l  __REG\1         ;  proc  <name>
  294.         rts
  295.         ENDM
  296.  
  297. args            MACRO                   ;put args on stack
  298. __ARGCNT        SET     NARG            ;  args  <param>,<param>,...
  299. CARG            SET     NARG
  300.         REPT    NARG
  301.         move.l  \-,-(sp)
  302.         ENDR
  303.         ENDM
  304.  
  305. margs           MACRO                   ;put more args on stack
  306. __ARGCNT        SET     NARG+__ARGCNT   ;  margs  <param>,<param>,...
  307. CARG            SET     NARG
  308.         REPT    NARG
  309.         move.l  \-,-(sp)
  310.         ENDR
  311.         ENDM
  312.  
  313. unargs          MACRO                   ;restore from last args
  314.         add.l   #__ARGCNT*4,sp  ;  unargs
  315.         ENDM
  316.  
  317.     ; The following macros will define strings in the DATA section!
  318.  
  319. leastr          MACRO                   ;  leastr     <string>,<address register>
  320.         lea     string\@,\2
  321.         SAVE
  322.         DATA
  323. string\@        dc.b    \1,0
  324.         even
  325.         RESTORE
  326.         ENDM
  327.  
  328. peastr          MACRO                   ;  peastr     <string>
  329.         pea     string\@
  330.         SAVE
  331.         DATA
  332. string\@        dc.b    \1,0
  333.         even
  334.         RESTORE
  335.         ENDM
  336.  
  337. defstr          MACRO                   ;  defstr     <label>,<string>
  338.         SAVE
  339.         DATA
  340. \1              dc.b    \2,0
  341.         even
  342.         RESTORE
  343.         ENDM
  344.  
  345. def             MACRO                   ; def.(b|w|l) <label>[,<label>...]
  346.         SAVE
  347.         BSS
  348.         REPT    NARG
  349. \+              ds.\0   1
  350.         ENDR
  351.         IFC     "\0","B"
  352.         even
  353.         ENDC
  354.         RESTORE
  355.         ENDM
  356.  
  357.     ; STRING OPERATIONS
  358.  
  359. copy            MACRO                   ;  copy.(b|w|l) <src>,<dest>
  360. .loop\@         move.\0 \1,\2
  361.         bne     .loop\@
  362.         ENDM
  363.  
  364. strln           MACRO                   ;  strlen.(b|w|l) <str>,<lenreg>
  365.         move.l  \1,\2           ;       String pointer is not changed!
  366. .loop\@         tst.\0  (\1)+
  367.         bne     .loop\@
  368.         sub.l   \2,\1
  369.         exg     \2,\1
  370.         IFC     "\0","w"
  371.          lsr.l  #1,\2
  372.         ENDC
  373.         IFC     "\0","l"
  374.          lsr.l  #2,\2
  375.         ENDC
  376.         ENDM
  377.  
  378. *-----------------------------------------------------------*
  379.         ENDC
  380.